package cn.gson.springboot.controllers;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.gson.springboot.model.pojos.DrugsYk;
import cn.gson.springboot.model.pojos.InventoryYk;
import cn.gson.springboot.model.service.InventoryYkService;
import cn.gson.springboot.model.vo.InventoryYkVO;

@Controller
public class InventoryYkController {
	@Autowired
	private InventoryYkService is;
	
	//查询所有药品信息
	@RequestMapping("kucunliebiao")
	@ResponseBody
	public Map<String,Object> hosLikeTableSmt(
			@RequestParam("page")int page,
			@RequestParam("rows")int rows,String drug_name){
		//进行分页
		Page<Object> pg = PageHelper.startPage(page, rows);
		JSONArray findall=is.findkucun(drug_name);
		//System.out.println("药品--"+findall);
		//进行数据格式转换和封装
		Map<String,Object> map = new HashMap<>();
		map.put("total", pg.getTotal());//封装总记录数
		map.put("rows", findall);//封装当前页的内容
			
		return map; 
	}
	
	//库存新增
	@RequestMapping("xinzeng")
	@ResponseBody
	public JSONArray findxinzeng(Integer inventory_yk_id,Integer aa) {
		return is.findxinzeng(inventory_yk_id, aa);
	}
	
	//库存减少
	@RequestMapping("jianshao")
	@ResponseBody
	public JSONArray findxjianshao(Integer inventory_yk_id,Integer bb) {
		//JSONArray findjianshao = is.findjianshao(inventory_yk_id, bb);
		return is.findjianshao(inventory_yk_id, bb);
	}

}
